package com.qykj.ddhing.pda.demo.databinding;

import android.arch.lifecycle.ViewModel;
import android.databinding.DataBindingUtil;
import android.databinding.Observable;
import android.databinding.ObservableArrayMap;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;

import com.qykj.ddhing.pda.R;
import com.qykj.ddhing.pda.common.LogUtil;
import com.qykj.ddhing.pda.databinding.DemoActivityLoginDatabindingBinding;

import java.util.ArrayList;
import java.util.List;


/**
 * author : 0000
 * desc   :
 * time   : 2018/07/19
 * updateTime : 2018/07/19
 */

public class LoginActivity extends AppCompatActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        DemoActivityLoginDatabindingBinding binding = DataBindingUtil.setContentView(this, R.layout.demo_activity_login_databinding);
        User user = new User("Test", "User");
        binding.setHandlers(new MyHandlers());
        binding.setPresenter(new Presenter());
        binding.setUser(user);
//        user.firstName="8888888";
        ObservableArrayMap<String, Object> user2 = new ObservableArrayMap<>();
        user2.put("firstName", "Google");
        user2.put("lastName", "Inc.");
        user2.put("age", 17);
//        binding.set
        List<User> users=new ArrayList<>();
        users.add(user);
        binding.setUserList(users);


        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            DataBindingUtils.addCallBack(this, user.goToSimple, new Observable.OnPropertyChangedCallback() {
                @Override
                public void onPropertyChanged(Observable observable, int i) {
                    LogUtil.getLogUtil_LXF().d("onPropertyChanged i:"+i);
                }
            });
        }
    }

}
